

function url_subStr(){

    var url = window.location.href;

    var url_one_array = url.split("://");
    var url_two_array = url_one_array[1].split("/");
    var new_url = "";
    for(var i = 1; i<url_two_array.length;i++){
        if(i != url_two_array.length-1){
            new_url +=url_two_array[i]+"/";
        }
    }
    new_url = new_url.substring(0,new_url.length-1);
    return new_url;
}
function btnClickArea() {
    var new_url = url_subStr();
    window.parent.areaEdit(new_url);
}
function btnClickBasic() {
    var new_url = url_subStr();
    window.parent.basic(new_url);
}
//获得本周7天的日期
function getCurrentWeekDays() {
    var now = new Date(); //当前日期
    var nowDayOfWeek = now.getDay(); //今天本周的第几天
    var nowDay = now.getDate(); //当前日
    var nowMonth = now.getMonth(); //当前月
    var nowYear = now.getYear(); //当前年
    var weekDays=[] ;
    for(var i=1 ; i <8 ;i++){
        var weekEndDate = new Date(nowYear, nowMonth, nowDay + (i - nowDayOfWeek)).getDate();
        weekDays[i-1] = weekEndDate  ;
    }
    return weekDays ;
}
/*获取一个月的天数 */
function getCurrentMouthDays() {
    var curDate = new Date();
    /* 获取当前月份 */
    var curMonth = curDate.getMonth();
    /*  生成实际的月份: 由于curMonth会比实际月份小1, 故需加1 */
    curDate.setMonth(curMonth + 1);
    /* 将日期设置为0, 这里为什么要这样设置, 我不知道原因, 这是从网上学来的 */
    curDate.setDate(0);
    /* 返回当月的天数 */

    return curDate.getDate();
}

function deleteArea(day){
    layer.confirm('确认删除当天所有配送地区？',function(){
        if('' == vm.supplier_id){
            return layer.msg('未登录');
        }
        if('' == day){
            return layer.msg('未选择日期');
        }
        $.ajax({
            url:"{:url('apishop/index/delAllAddressBySupplierIdDay')}",
            type:'post',
            data:{
                supplier_id:vm.supplier_id,
                day:day
            },
            success:function(ret){
                layer.msg(ret.msg);
                if(200 == ret.status){
                    setTimeout(function(){
                        window.location.reload();
                    },1000);
                }
            }
        });
    });
}



//打开地址框
function openAddressModel() {
    vm.address = [];
    $('.collection_confirm_box').fadeIn(300);
}
//关闭地址框
function closeAddressModel() {
    $('.collection_confirm_box').fadeOut(300);
}



